#!/usr/bin/env python
import os
import numpy as np
import matplotlib.pyplot as plt

for i in range(0, 9):
    for j in range(0, 4):
        file_path = f"/home/zxg/be-cu_dp_course/dpgen/run/iter.00000{i}/00.train/00{j}/lcurve.out"
        data = np.genfromtxt(file_path, names=True)
        for name in data.dtype.names[1:-1]:
            plt.plot(data['step'], data[name], label=name)
        plt.legend()
        plt.xlabel('Step')
        plt.ylabel('Loss')
        plt.yscale('log')
        plt.xscale('log')
        plt.savefig(f'inter{i}_{j}_lcurve_nolog.png')
        print(f'finish the plt of inter{i}_{j}_lcurve')
        plt.clf()